﻿using System;
using System.Collections.Generic;
using System.Text;
using YookingBizWQW.Class.Public;
using YookingFileIO.Class;
using YookingSvrDBCall.Class.DBLogic;
using YookingSvrDBCall.Class.DBPub;

namespace YookingBizWQW.Class.Credit.mp
{
    public class clsCrHmData
    {
        //注释：王庆文 2020年03月18日===================================================
        //统计分析当前登录用户的佣金总额、已支取佣金、当前账户余额等信息
        public string OlapMemberBkgeAmount(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            #region 将strRequestData包含的各种参数一一解析出来

            string strUnitCode = "CHN000"; //平台平台编码
            string strMID = "00000000000"; //会员编码
            string strCondition = "1=1";   //附加查询条件

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length >= 3)
            {
                strUnitCode = strArray[0];
                strMID = strArray[1];
                strCondition = strArray[2];
            }

            #endregion

            #region 生成查询记录的SQL语句

            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine(" SELECT ");
            sbQuerySQL.AppendLine(" 	ROUND(IFNULL(ALLAMOUNT, '0.00'), 2) ALLAMOUNT, /*佣金总额*/ ");
            sbQuerySQL.AppendLine(" 	ROUND(IFNULL(YZQAMOUNT, '0.00'), 2) YZQAMOUNT, /*已支取*/ ");
            sbQuerySQL.AppendLine(" 	ROUND(IFNULL(WZQAMOUNT, '0.00'), 2) WZQAMOUNT  /*当前余额*/ ");
            sbQuerySQL.AppendLine(" FROM ");
            sbQuerySQL.AppendLine(" 	( ");
            sbQuerySQL.AppendLine(" 		SELECT SUM(BKGEAMOUNT) AS ALLAMOUNT FROM XYK_INCOME_BILL ");
            sbQuerySQL.AppendLine(" 		WHERE 1=1 AND ISSUCCESS='1' AND " + clsSQLSyntax.IsNullSQL("Data", "SYS_CANCELDATETIME") + " AND UNITCODE = '" + strUnitCode + "' AND RECECODE='" + strMID + "' AND " + strCondition);
            sbQuerySQL.AppendLine(" 	) T ");
            sbQuerySQL.AppendLine(" LEFT JOIN ( /*已支取*/ ");
            sbQuerySQL.AppendLine(" 	SELECT sum(BKGEAMOUNT) AS YZQAMOUNT FROM XYK_INCOME_BILL ");
            sbQuerySQL.AppendLine(" 	WHERE ATMState='1' AND ISSUCCESS='1' AND  " + clsSQLSyntax.IsNullSQL("Data", "SYS_CANCELDATETIME") + " AND UNITCODE = '" + strUnitCode + "' AND RECECODE='" + strMID + "' AND " + strCondition);
            sbQuerySQL.AppendLine(" ) A ON 1=1 ");
            sbQuerySQL.AppendLine(" LEFT JOIN ( /*当前余额*/ ");
            sbQuerySQL.AppendLine(" 	SELECT sum(BKGEAMOUNT) AS WZQAMOUNT FROM XYK_INCOME_BILL ");
            sbQuerySQL.AppendLine(" 	WHERE ATMState='0' AND ISSUCCESS='1' AND " + clsSQLSyntax.IsNullSQL("Data", "SYS_CANCELDATETIME") + " AND UNITCODE = '" + strUnitCode + "' AND RECECODE='" + strMID + "' AND " + strCondition);
            sbQuerySQL.AppendLine(" ) B ON 1=1 ");

            #endregion

            //clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            //myLog.WriteInfoToTxtFile("SysLog", "wqw_clsCrHmData_OlapMemberBkgeAmount.txt", sbQuerySQL.ToString());

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            strRtData = myDB.YookingExecuteJson("Data", sbQuerySQL.ToString());

            return strRtData; //数据库查询结果
        }

        //注释：王庆文 2020年03月18日===================================================
        //统计分析当前登录用户的一、二级代理人数、上月佣金总额、本月佣金总额
        public string OlapMemberAgentAndBrokerage(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            #region 将strRequestData包含的各种参数一一解析出来

            string strUnitCode = "CHN000"; //平台平台编码
            string strMID = "00000000000"; //会员编码

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length >= 2)
            {
                strUnitCode = strArray[0];
                strMID = strArray[1];
            }

            #endregion

            #region 生成查询记录的SQL语句

            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine(" SELECT ");
            sbQuerySQL.AppendLine(" 	ROUND(IFNULL(RHGAMOUNT, '0'), 2) RHGAMOUNT, ");
            sbQuerySQL.AppendLine(" 	AAGENTCOUNT, ");
            sbQuerySQL.AppendLine(" 	ROUND(IFNULL(ALSTMONTHBKGE, '0'),2) ALSTMONTHBKGE, ");
            sbQuerySQL.AppendLine(" 	ROUND(IFNULL(ALCLMONTHBKGE, '0'),2) ALCLMONTHBKGE, ");
            sbQuerySQL.AppendLine(" 	BAGENTCOUNT, ");
            sbQuerySQL.AppendLine(" 	ROUND(IFNULL(BLSTMONTHBKGE, '0'),2) BLSTMONTHBKGE, ");
            sbQuerySQL.AppendLine(" 	ROUND(IFNULL(BLCLMONTHBKGE, '0'),2) BLCLMONTHBKGE ");
            sbQuerySQL.AppendLine(" FROM ");
            sbQuerySQL.AppendLine(" 	( ");
            sbQuerySQL.AppendLine(" 		/*会员充值金额*/ ");
            sbQuerySQL.AppendLine(" 		SELECT SUM(PAYAMOUNT) AS RHGAMOUNT FROM XYK_RECHARGEPOOL ");
            sbQuerySQL.AppendLine(" 		WHERE " + clsSQLSyntax.IsNullSQL("Data", "SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" 		AND ISSUCCESS = '1' "); //0=充值失败，1=充值成功
            sbQuerySQL.AppendLine(" 		AND UNITCODE = '" + strUnitCode + "' ");
            sbQuerySQL.AppendLine(" 		AND PAYPERSON = '" + strMID + "' ");
            sbQuerySQL.AppendLine(" 	) A ");
            sbQuerySQL.AppendLine(" LEFT JOIN ( ");
            sbQuerySQL.AppendLine(" 	/*一级代理人数*/ ");
            sbQuerySQL.AppendLine(" 	SELECT COUNT(*) AS AAGENTCOUNT FROM XYK_MEMBER_INFO ");
            sbQuerySQL.AppendLine(" 	WHERE " + clsSQLSyntax.IsNullSQL("Data", "SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" 	AND UNITCODE = '" + strUnitCode + "' ");
            sbQuerySQL.AppendLine(" 	AND PID = '" + strMID + "' ");
            sbQuerySQL.AppendLine(" 	AND (ISBINDCARD='1' OR MEMBERLEVEL!='00') "); //只计算绑卡的人，或非普通会员
            sbQuerySQL.AppendLine(" ) B ON 1 = 1 ");
            sbQuerySQL.AppendLine(" LEFT JOIN ( ");
            sbQuerySQL.AppendLine(" 	/*一级代理上月所得佣金*/ ");
            sbQuerySQL.AppendLine(" 	SELECT SUM(BKGEAMOUNT) AS ALSTMONTHBKGE FROM XYK_INCOME_BILL ");
            sbQuerySQL.AppendLine(" 	WHERE " + clsSQLSyntax.IsNullSQL("Data", "SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" 	AND UNITCODE = '" + strUnitCode + "' ");
            sbQuerySQL.AppendLine(" 	AND RECECODE = '" + strMID + "' ");
            sbQuerySQL.AppendLine(" 	AND BKGETYPE = '01' ");
            sbQuerySQL.AppendLine("     AND ISSUCCESS = '1' "); //0=返佣失败，1=返佣成功
            sbQuerySQL.AppendLine(" 	AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),DATE_FORMAT(BKGETIME, '%Y%m'))=1 ");
            sbQuerySQL.AppendLine(" ) C ON 1 = 1 ");
            sbQuerySQL.AppendLine(" LEFT JOIN ( ");
            sbQuerySQL.AppendLine(" 	/*一级代理本月所得佣金*/ ");
            sbQuerySQL.AppendLine(" 	SELECT SUM(BKGEAMOUNT) AS ALCLMONTHBKGE FROM XYK_INCOME_BILL ");
            sbQuerySQL.AppendLine(" 	WHERE " + clsSQLSyntax.IsNullSQL("Data", "SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" 	AND UNITCODE = '" + strUnitCode + "' ");
            sbQuerySQL.AppendLine(" 	AND RECECODE = '" + strMID + "' ");
            sbQuerySQL.AppendLine(" 	AND BKGETYPE = '01' ");
            sbQuerySQL.AppendLine("     AND ISSUCCESS = '1' "); //0=返佣失败，1=返佣成功
            sbQuerySQL.AppendLine(" 	AND DATE_FORMAT(BKGETIME, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m') ");
            sbQuerySQL.AppendLine(" ) D ON 1 = 1 ");
            sbQuerySQL.AppendLine(" LEFT JOIN ( ");
            sbQuerySQL.AppendLine(" 	/*二级代理人数*/ ");
            sbQuerySQL.AppendLine(" 	SELECT COUNT(*) AS BAGENTCOUNT ");
            sbQuerySQL.AppendLine(" 	FROM XYK_MEMBER_INFO ");
            sbQuerySQL.AppendLine(" 	WHERE " + clsSQLSyntax.IsNullSQL("Data", "SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" 	AND UNITCODE = '" + strUnitCode + "' ");
            sbQuerySQL.AppendLine(" 	AND GPID = '" + strMID + "' ");
            sbQuerySQL.AppendLine(" 	AND PID <> '" + strMID + "' ");
            sbQuerySQL.AppendLine(" 	AND (ISBINDCARD='1' OR MEMBERLEVEL!='00') "); //只计算绑卡的人，或非普通会员
            sbQuerySQL.AppendLine(" ) E ON 1 = 1 ");
            sbQuerySQL.AppendLine(" LEFT JOIN ( ");
            sbQuerySQL.AppendLine(" 	/*二级代理上月所得佣金*/ ");
            sbQuerySQL.AppendLine(" 	SELECT SUM(BKGEAMOUNT) AS BLSTMONTHBKGE FROM XYK_INCOME_BILL ");
            sbQuerySQL.AppendLine(" 	WHERE " + clsSQLSyntax.IsNullSQL("Data", "SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" 	AND UNITCODE = '" + strUnitCode + "' ");
            sbQuerySQL.AppendLine(" 	AND RECECODE = '" + strMID + "' ");
            sbQuerySQL.AppendLine(" 	AND BKGETYPE = '02' ");
            sbQuerySQL.AppendLine("     AND ISSUCCESS = '1' "); //0=返佣失败，1=返佣成功
            sbQuerySQL.AppendLine(" 	AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),DATE_FORMAT(BKGETIME, '%Y%m'))=1 ");
            sbQuerySQL.AppendLine(" ) F ON 1 = 1 ");
            sbQuerySQL.AppendLine(" LEFT JOIN ( ");
            sbQuerySQL.AppendLine(" 	/*二级代理本月所得佣金*/ ");
            sbQuerySQL.AppendLine(" 	SELECT SUM(BKGEAMOUNT) AS BLCLMONTHBKGE FROM XYK_INCOME_BILL ");
            sbQuerySQL.AppendLine(" 	WHERE " + clsSQLSyntax.IsNullSQL("Data", "SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" 	AND UNITCODE = '" + strUnitCode + "' ");
            sbQuerySQL.AppendLine(" 	AND RECECODE = '" + strMID + "' ");
            sbQuerySQL.AppendLine(" 	AND BKGETYPE = '02' ");
            sbQuerySQL.AppendLine("     AND ISSUCCESS = '1' "); //0=返佣失败，1=返佣成功
            sbQuerySQL.AppendLine(" 	AND DATE_FORMAT(BKGETIME, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m') ");
            sbQuerySQL.AppendLine(" ) G ON 1 = 1 ");

            #endregion

            //clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            //myLog.WriteInfoToTxtFile("SysLog", "pz_clsCrHmData_OlapMemberAgentAndBrokerage.txt", sbQuerySQL.ToString(),false);

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            strRtData = myDB.YookingExecuteJson("Data", sbQuerySQL.ToString());

            return strRtData; //数据库查询结果
        }

        //注释：王庆文 2020年03月18日===================================================
        //图形图表，分析当前用户本年度收入趋势，从01月 ... 12月
        public string OlapMemberIncome(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            #region 将strRequestData包含的各种参数一一解析出来

            string strUnitCode = "CHN000"; //平台平台编码
            string strMID = "00000000000"; //会员编码

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length >= 2)
            {
                strUnitCode = strArray[0];
                strMID = strArray[1];
            }

            #endregion

            #region 生成查询记录的SQL语句

            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine(" SELECT DISTINCT A.MONTH,ROUND(IFNULL(B.BKGESUM,'0'),2) BKGESUM FROM ( ");
            sbQuerySQL.AppendLine(" 		SELECT '01' MONTH FROM XYK_INCOME_BILL ");
            sbQuerySQL.AppendLine(" 		UNION SELECT '02' MONTH FROM XYK_INCOME_BILL ");
            sbQuerySQL.AppendLine(" 		UNION SELECT '03' MONTH FROM XYK_INCOME_BILL ");
            sbQuerySQL.AppendLine(" 		UNION SELECT '04' MONTH FROM XYK_INCOME_BILL ");
            sbQuerySQL.AppendLine(" 		UNION SELECT '05' MONTH FROM XYK_INCOME_BILL ");
            sbQuerySQL.AppendLine(" 		UNION SELECT '06' MONTH FROM XYK_INCOME_BILL ");
            sbQuerySQL.AppendLine(" 		UNION SELECT '07' MONTH FROM XYK_INCOME_BILL ");
            sbQuerySQL.AppendLine(" 		UNION SELECT '08' MONTH FROM XYK_INCOME_BILL ");
            sbQuerySQL.AppendLine(" 		UNION SELECT '09' MONTH FROM XYK_INCOME_BILL ");
            sbQuerySQL.AppendLine(" 		UNION SELECT '10' MONTH FROM XYK_INCOME_BILL ");
            sbQuerySQL.AppendLine(" 		UNION SELECT '11' MONTH FROM XYK_INCOME_BILL ");
            sbQuerySQL.AppendLine(" 		UNION SELECT '12' MONTH FROM XYK_INCOME_BILL ) A ");
            sbQuerySQL.AppendLine(" LEFT JOIN ( ");
            sbQuerySQL.AppendLine("     SELECT SUM(BKGEAMOUNT) BKGESUM,SUBSTR(BKGETIME,6,2) MONTH FROM XYK_INCOME_BILL ");
            sbQuerySQL.AppendLine("       WHERE " + clsSQLSyntax.IsNullSQL("Data", "SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine("         AND UNITCODE='" + strUnitCode + "' ");
            sbQuerySQL.AppendLine("         AND RECECODE='" + strMID + "' ");
            sbQuerySQL.AppendLine("         AND BKGETIME>=CONCAT(DATE_FORMAT(NOW(),'%Y'),'-01-01 00:00:00') ");
            sbQuerySQL.AppendLine("         AND BKGETIME<=CONCAT(DATE_FORMAT(NOW(),'%Y'),'-12-31 23:59:59') ");
            sbQuerySQL.AppendLine("         AND ISSUCCESS='1' "); //0=返佣失败，1=返佣成功
            sbQuerySQL.AppendLine(" GROUP BY SUBSTR(BKGETIME,6,2) ");
            sbQuerySQL.AppendLine(" ) B ON A.MONTH=B.MONTH ORDER BY A.MONTH ");

            #endregion

            //clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            //myLog.WriteInfoToTxtFile("SysLog", "wqw_clsCrHmData_OlapMemberIncome.txt", sbQuerySQL.ToString());

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            strRtData = myDB.YookingExecuteJson("Data", sbQuerySQL.ToString());

            return strRtData; //数据库查询结果
        }

        //注释：王庆文 2020年03月18日===================================================
        //图形图表，分析当前用户一级代理、二级代理人数情况
        public string OlapMemberAgentCount(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            #region 将strRequestData包含的各种参数一一解析出来

            string strUnitCode = "CHN000"; //平台平台编码
            string strMID = "00000000000"; //会员编码

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length >= 2)
            {
                strUnitCode = strArray[0];
                strMID = strArray[1];
            }

            #endregion

            #region 生成查询记录的SQL语句

            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine(" SELECT A.LEVELCODE,A.LEVELMEMO,IFNULL(B.ACOUNT,'0') ACOUNT,IFNULL(C.BCOUNT,'0') BCOUNT FROM ( ");
            sbQuerySQL.AppendLine("     SELECT DISTINCT LEVELCODE,LEVELMEMO FROM XYK_MEMBER_LEVEL  ");
            sbQuerySQL.AppendLine("     WHERE " + clsSQLSyntax.IsNullSQL("Data", "SYS_CANCELDATETIME") + ") A ");
            sbQuerySQL.AppendLine("     LEFT JOIN ( ");
            sbQuerySQL.AppendLine("        SELECT COUNT(*) ACOUNT,MEMBERLEVEL FROM XYK_MEMBER_INFO ");
            sbQuerySQL.AppendLine("           WHERE " + clsSQLSyntax.IsNullSQL("Data", "SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" 	      AND (ISBINDCARD='1' OR MEMBERLEVEL!='00') "); //只计算绑卡的人，或非普通会员
            sbQuerySQL.AppendLine("           AND UNITCODE='" + strUnitCode + "' ");
            sbQuerySQL.AppendLine("           AND PID='" + strMID + "' GROUP BY MEMBERLEVEL ) B ");
            sbQuerySQL.AppendLine("      ON A.LEVELCODE=B.MEMBERLEVEL ");
            sbQuerySQL.AppendLine("     LEFT JOIN ( ");
            sbQuerySQL.AppendLine("        SELECT COUNT(*) BCOUNT,MEMBERLEVEL FROM XYK_MEMBER_INFO ");
            sbQuerySQL.AppendLine("           WHERE " + clsSQLSyntax.IsNullSQL("Data", "SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" 	      AND (ISBINDCARD='1' OR MEMBERLEVEL!='00') "); //只计算绑卡的人，或非普通会员
            sbQuerySQL.AppendLine("           AND UNITCODE='" + strUnitCode + "' ");
            sbQuerySQL.AppendLine("           AND GPID='" + strMID + "' AND PID!='" + strMID + "' GROUP BY MEMBERLEVEL ) C ");
            sbQuerySQL.AppendLine("     ON A.LEVELCODE=C.MEMBERLEVEL ORDER BY A.LEVELCODE ");

            #endregion

            //clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            //myLog.WriteInfoToTxtFile("SysLog", "wqw_clsCrHmData_OlapMemberAgentCount.txt", sbQuerySQL.ToString());

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            strRtData = myDB.YookingExecuteJson("Data", sbQuerySQL.ToString());

            return strRtData; //数据库查询结果
        }

        //注释：王庆文 2020年03月18日===================================================
        //查询信用卡还款平台发布的文章资讯信息，每次只查询N条
        public string GetArticleInfo(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            #region 将strRequestData包含的各种参数一一解析出来

            string strUnitCode = "CHN000"; //平台平台编码
            string strRNBegin = "1"; //查询开始条数
            string strRNEnd = "10";  //查询结束条数
            string strSQLCondition = "1=1"; //其他附加查询条件

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length >= 4)
            {
                strUnitCode = strArray[0];
                strRNBegin = strArray[1];
                strRNEnd = strArray[2];
                strSQLCondition = strArray[3];
            }

            #endregion

            #region 生成查询记录的SQL语句

            clsDBSpace mySpace = new clsDBSpace(); //表空间名
            string strSysSapace = mySpace.GetDBSpaceName("Sys");

            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine(" SELECT ");
            sbQuerySQL.AppendLine(" 	SYS_RECORDID, ");
            sbQuerySQL.AppendLine(" 	INFOID, ");
            sbQuerySQL.AppendLine(" 	PUBLISHTIME, ");
            sbQuerySQL.AppendLine(" 	INFOTITLE, ");
            sbQuerySQL.AppendLine(" 	INFOURL, ");
            sbQuerySQL.AppendLine(" 	INFOCONTENT, ");
            sbQuerySQL.AppendLine(" 	READCOUNT, ");
            sbQuerySQL.AppendLine(" 	ENJOYCOUNT, ");
            sbQuerySQL.AppendLine(" 	OTHERMEMO, ");
            sbQuerySQL.AppendLine(" 	PERSONNAME, ");
            sbQuerySQL.AppendLine(" 	PERSONIMAGEENTITY, /*人员图片*/ ");
            sbQuerySQL.AppendLine(" 	IMAGEENTITY1, /*资讯图片1*/ ");
            sbQuerySQL.AppendLine(" 	IMAGEENTITY2 /*资讯图片2*/ ");
            sbQuerySQL.AppendLine(" FROM ");
            sbQuerySQL.AppendLine(" 	( ");
            sbQuerySQL.AppendLine(" 		SELECT ");
            sbQuerySQL.AppendLine(" 	        T.SYS_RECORDID, ");
            sbQuerySQL.AppendLine(" 	        T.INFOID, ");
            sbQuerySQL.AppendLine(" 			T.PUBLISHTIME, ");
            sbQuerySQL.AppendLine(" 			T.INFOTITLE, ");
            sbQuerySQL.AppendLine(" 			T.INFOURL, ");
            sbQuerySQL.AppendLine(" 			T.INFOCONTENT, ");
            sbQuerySQL.AppendLine(" 			T.READCOUNT, ");
            sbQuerySQL.AppendLine(" 			T.ENJOYCOUNT, ");
            sbQuerySQL.AppendLine(" 	        T.OTHERMEMO, ");
            sbQuerySQL.AppendLine(" 			A.PERSONNAME, ");
            sbQuerySQL.AppendLine(" 			PERSONIMAGEENTITY, ");
            sbQuerySQL.AppendLine(" 			IMAGEENTITY1, ");
            sbQuerySQL.AppendLine(" 			IMAGEENTITY2, ");
            sbQuerySQL.AppendLine(" 			ROW_NUMBER () OVER (PARTITION BY T.UNITCODE ORDER BY T.PUBLISHTIME DESC) RN ");
            sbQuerySQL.AppendLine(" 		FROM XYK_INFOPUBLISH T ");
            sbQuerySQL.AppendLine(" 		LEFT JOIN SA_ORG_PERSONINFO A ON T.PERSONCODE = A.PERSONCODE ");
            sbQuerySQL.AppendLine(" 		LEFT JOIN ( ");
            sbQuerySQL.AppendLine(" 			SELECT ");
            sbQuerySQL.AppendLine(" 				M.IMAGEENTITY PERSONIMAGEENTITY, ");
            sbQuerySQL.AppendLine(" 				M.MAINTABLERECORDID ");
            sbQuerySQL.AppendLine(" 			FROM ");
            sbQuerySQL.AppendLine(" 				( ");
            sbQuerySQL.AppendLine(" 					SELECT ");
            sbQuerySQL.AppendLine(" 						IMAGEENTITY, ");
            sbQuerySQL.AppendLine(" 						MAINTABLERECORDID, ");
            sbQuerySQL.AppendLine(" 						ROW_NUMBER () OVER (PARTITION BY MAINTABLEDEFINEID,MAINTABLERECORDID ORDER BY T.SYS_RECORDID DESC) RN ");
            sbQuerySQL.AppendLine(" 					FROM MDA_PUBLICIMAGE T ");
            sbQuerySQL.AppendLine(" 					LEFT JOIN "+ strSysSapace + ".DB_TABLEDEFINE A ON (T.MAINTABLEDEFINEID = A.TABLEID OR upper(T.MAINTABLEDEFINEID) = 'SA_ORG_PERSONINFO') ");
            sbQuerySQL.AppendLine(" 					WHERE " + clsSQLSyntax.IsNullSQL("Data", "T.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" 					AND " + clsSQLSyntax.IsNullSQL("Data", "A.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" 					AND upper(A.TABLENAME) = 'SA_ORG_PERSONINFO' /*查询Sa_Org_PersonInfo的图片*/ ");
            sbQuerySQL.AppendLine(" 				) M ");
            sbQuerySQL.AppendLine(" 			WHERE M.RN = '1' ");
            sbQuerySQL.AppendLine(" 		) B ON A.SYS_RECORDID = B.MAINTABLERECORDID ");
            sbQuerySQL.AppendLine(" 		LEFT JOIN ( ");
            sbQuerySQL.AppendLine(" 			SELECT ");
            sbQuerySQL.AppendLine(" 				M.IMAGEENTITY IMAGEENTITY1, ");
            sbQuerySQL.AppendLine(" 				M.MAINTABLERECORDID ");
            sbQuerySQL.AppendLine(" 			FROM ");
            sbQuerySQL.AppendLine(" 				( ");
            sbQuerySQL.AppendLine(" 					SELECT ");
            sbQuerySQL.AppendLine(" 						IMAGEENTITY, ");
            sbQuerySQL.AppendLine(" 						MAINTABLERECORDID, ");
            sbQuerySQL.AppendLine(" 						ROW_NUMBER () OVER (PARTITION BY MAINTABLEDEFINEID,MAINTABLERECORDID ORDER BY T.SYS_RECORDID DESC) RN ");
            sbQuerySQL.AppendLine(" 					FROM MDA_PUBLICIMAGE T ");
            sbQuerySQL.AppendLine(" 					LEFT JOIN " + strSysSapace + ".DB_TABLEDEFINE A ON (T.MAINTABLEDEFINEID = A.TABLEID OR upper(T.MAINTABLEDEFINEID) = 'XYK_INFOPUBLISH')  ");
            sbQuerySQL.AppendLine(" 					WHERE " + clsSQLSyntax.IsNullSQL("Data", "T.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" 					AND " + clsSQLSyntax.IsNullSQL("Data", "A.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" 					AND upper(A.TABLENAME) = 'XYK_INFOPUBLISH' /*查询XYK_InfoPublish的图片*/ ");
            sbQuerySQL.AppendLine(" 				) M ");
            sbQuerySQL.AppendLine(" 			WHERE M.RN = '1' ");
            sbQuerySQL.AppendLine(" 		) C ON T.SYS_RECORDID = C.MAINTABLERECORDID ");
            sbQuerySQL.AppendLine(" 		LEFT JOIN ( ");
            sbQuerySQL.AppendLine(" 			SELECT ");
            sbQuerySQL.AppendLine(" 				M.IMAGEENTITY IMAGEENTITY2, ");
            sbQuerySQL.AppendLine(" 				M.MAINTABLERECORDID ");
            sbQuerySQL.AppendLine(" 			FROM ");
            sbQuerySQL.AppendLine(" 				( ");
            sbQuerySQL.AppendLine(" 					SELECT ");
            sbQuerySQL.AppendLine(" 						IMAGEENTITY, ");
            sbQuerySQL.AppendLine(" 						MAINTABLERECORDID, ");
            sbQuerySQL.AppendLine(" 						ROW_NUMBER () OVER (PARTITION BY MAINTABLEDEFINEID,MAINTABLERECORDID ORDER BY T.SYS_RECORDID DESC) RN ");
            sbQuerySQL.AppendLine(" 					FROM MDA_PUBLICIMAGE T ");
            sbQuerySQL.AppendLine(" 					LEFT JOIN " + strSysSapace + ".DB_TABLEDEFINE A ON (T.MAINTABLEDEFINEID = A.TABLEID OR upper(T.MAINTABLEDEFINEID) = 'XYK_INFOPUBLISH') ");
            sbQuerySQL.AppendLine(" 					WHERE " + clsSQLSyntax.IsNullSQL("Data", "T.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" 					AND " + clsSQLSyntax.IsNullSQL("Data", "A.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" 					AND upper(A.TABLENAME) = 'XYK_INFOPUBLISH' /*查询XYK_InfoPublish的图片*/ ");
            sbQuerySQL.AppendLine(" 				) M ");
            sbQuerySQL.AppendLine(" 			WHERE M.RN = '2' ");
            sbQuerySQL.AppendLine(" 		) D ON T.SYS_RECORDID = D.MAINTABLERECORDID ");
            sbQuerySQL.AppendLine(" 		WHERE " + clsSQLSyntax.IsNullSQL("Data", "T.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" 		AND " + clsSQLSyntax.IsNullSQL("Data", "A.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" 		AND T.UNITCODE = '" + strUnitCode + "' /*单位编码*/ ");
            sbQuerySQL.AppendLine(" 		AND " + strSQLCondition + " /*其他附加条件*/ ");
            sbQuerySQL.AppendLine(" 	) S ");
            sbQuerySQL.AppendLine(" WHERE S.RN BETWEEN '" + strRNBegin + "' /*查询开始条数*/ ");
            sbQuerySQL.AppendLine(" AND '" + strRNEnd + "' /*查询结束条数*/ ");

            #endregion

            //clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            //myLog.WriteInfoToTxtFile("SysLog", "wqw_clsCrHmData_GetArticleInfo.txt", sbQuerySQL.ToString());

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            strRtData = myDB.YookingExecuteJson("Data", sbQuerySQL.ToString());

            return strRtData; //数据库查询结果
        }

        //注释：王庆文 2020年05月31日===================================================
        //查询信用卡还款平台发布的某一文章资讯的详细信息
        public string GetArticleDetail(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            #region 将strRequestData包含的各种参数一一解析出来

            string strUnitCode = "CHN000"; //平台平台编码
            string strSys_RecordID = "00"; //资讯记录ID

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length >= 2)
            {
                strUnitCode = strArray[0];
                strSys_RecordID = strArray[1];
            }

            #endregion

            #region 生成查询记录的SQL语句

            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine(" SELECT ");
            sbQuerySQL.AppendLine(" 	T.INFOID, ");
            sbQuerySQL.AppendLine(" 	T.UNITCODE, ");
            sbQuerySQL.AppendLine(" 	T.PERSONCODE, ");
            sbQuerySQL.AppendLine(" 	T.PUBLISHTIME, ");
            sbQuerySQL.AppendLine(" 	T.INFOTITLE, ");
            sbQuerySQL.AppendLine(" 	T.INFOURL, ");
            sbQuerySQL.AppendLine(" 	T.INFOCONTENT, ");
            sbQuerySQL.AppendLine(" 	T.READCOUNT, ");
            sbQuerySQL.AppendLine(" 	T.ENJOYCOUNT, ");
            sbQuerySQL.AppendLine(" 	T.OTHERMEMO, ");
            sbQuerySQL.AppendLine(" 	T.SYS_RECORDID, ");
            sbQuerySQL.AppendLine(" 	A.IMAGEENTITY ");
            sbQuerySQL.AppendLine(" FROM XYK_INFOPUBLISH T ");
            sbQuerySQL.AppendLine(" LEFT JOIN MDA_PUBLICIMAGE A ON T.SYS_RECORDID = A.MAINTABLERECORDID ");
            sbQuerySQL.AppendLine(" WHERE " + clsSQLSyntax.IsNullSQL("Data", "T.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" AND " + clsSQLSyntax.IsNullSQL("Data", "A.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" AND T.UNITCODE = '" + strUnitCode + "' /*单位编码*/ ");
            sbQuerySQL.AppendLine(" AND T.SYS_RECORDID = '" + strSys_RecordID + "' /*资讯Sys_RecoRdID*/ ");
            sbQuerySQL.AppendLine(" ORDER BY A.SPECIALRELATENUMBER ");

            #endregion

            //clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            //myLog.WriteInfoToTxtFile("SysLog", "wqw.txt", sbQuerySQL.ToString());

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            strRtData = myDB.YookingExecuteJson("Data", sbQuerySQL.ToString());

            return strRtData; //数据库查询结果
        }

        //注释：王庆文 2020年03月18日========================================================
        //文章资讯的阅读、或者点赞次数+1
        public string UpdateArticleCount_ReadEnjoy(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            #region 将strRequestData包含的各种参数一一解析出来

            string strColumnName = "AAAA"; //被加1的字段名称
            string strSys_RecordID = "00"; //被update的记录ID

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length >= 2)
            {
                strColumnName = strArray[0];
                strSys_RecordID = strArray[1];
            }

            #endregion

            #region 生成查询记录的SQL语句

            StringBuilder sbUpdateSQL = new StringBuilder();
            sbUpdateSQL.AppendLine(" UPDATE XYK_INFOPUBLISH ");
            sbUpdateSQL.AppendLine(" SET " + strColumnName + "=" + strColumnName + "+1 ");
            sbUpdateSQL.AppendLine(" WHERE Sys_RecordID = '" + strSys_RecordID + "' ");

            #endregion

            //clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            //myLog.WriteInfoToTxtFile("SysLog", "wqw.txt", sbUpdateSQL.ToString());

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            object objResult = myDB.YookingExecuteNonQuery("Data", sbUpdateSQL.ToString());
            strRtData = objResult.ToString(); //得到受影响的行数

            return strRtData; //数据库操作结果
        }





    }
}
